<!DOCTYPE html>
<html  lang="en" xmlns:th="http://www.thymeleaf.org">
	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" href="layui/css/layui.css"/>
		<link rel="stylesheet" href="layui/css/admin.css"/>
		<link rel="stylesheet" href="layui/css/modules/layer/default/layer.css" />
		<style type="text/css">
		  .card{		  
		     height:135px;
		  }
		</style>
	</head>
	<body class="layui-layout-body" layadmin-themealias="green">
		<div class="layui-fluid">
			<div class="layui-row layui-col-space15">
					<div class="layui-row layui-col-space15">
					<!-- 
						<div class="layui-col-md4">
							<div class="layui-card">
								<div class="layui-card-header">待办事项</div>
								<div class="layui-card-body">
									<div class="layui-carousel layadmin-carousel layadmin-shortcut layadmin-backlog" 
										style="width: 100%;height: 100px;" lay-arrow="none" lay-indicator="inside"lay-anim="">
									  <div carousel-item="">
									  	<ul class="layui-row layui-col-space10 layui-this">
									  		<li class="layui-col-xs6">
									  			<a class="layadmin-backlog-body" lay-href="#">
									  				<h2>待批假期</h2>
									  				<p><cite>44</cite></p>
									  			</a>
									  		</li>
									  		<li class="layui-col-xs6">
									  			<a class="layadmin-backlog-body" lay-href="#">
									  				<h2>待批假期</h2>
									  			    <p><cite>565</cite></p>
									  			</a>
									  			
									  		</li>
									  	</ul>
									  	<ul class="layui-row layui-col-space10">
									  		<li class="layui-col-xs3">
									  			<a href="#">待审人员</a>
									  		</li>
									  	</ul>
									  </div>
									  <div class="layui-carousel-ind">
									  	<ul>
									  		<li class="layui-this"></li>
									  		<li class=""></li>
									  	</ul>
									  </div>
									  <button class=" layui-icon layui-carousel-arrow" lay-type="sub"></button>
									  <button class="layui-icon layui-carousel-arrow" lay-type="add"></button>
									</div>
								</div>
							</div>
						</div>
						 -->
						<div class="layui-col-md4">
							<div class="layui-card">
								<div class="layui-card-header">快捷入口</div>
								<div class="layui-card-body">
									<div class="layui-carousel layadmin-carousel layadmin-shortcut layadmin-backlog card" 
										style="width: 100%;" lay-arrow="none" lay-indicator="inside"lay-anim="">
									  <div carousel-item="">
									  	<ul class="layui-row layui-col-space10 layui-this">
									  		<li class="layui-col-xs4">
									  			<a class="layadmin-backlog-body" href="/toAddressList" >
									  			    <i class="layui-icon">&#xe613;</i>
									  				<h2>通讯录</h2>
									  				<p><cite></cite></p>
									  			</a>
									  		</li>
									  		<li class="layui-col-xs4">
									  			<a class="layadmin-backlog-body" lay-href="#" onclick="attendance()">
									  			    <i class="layui-icon">&#xe60e;</i>
									  				<h2>打卡</h2>
									  			    <p><cite></cite></p>
									  			</a>
									  			
									  		</li>
									  		<li class="layui-col-xs4">
									  			<a class="layadmin-backlog-body" lay-href="#" onclick="vacate()">
									  			   <i class="layui-icon">&#xe637;</i>
									  				<h2>请假</h2>
									  				<p><cite></cite></p>
									  			</a>
									  		</li>
									  	</ul>
									
									  </div>
								
									</div>
								</div>
							</div>
						</div>
						
						<div class="layui-col-md8">
							<div class="layui-card">
							  <div class="layui-card-header">通知</div>
								<div class="layui-card-body">
								
									<div class="layui-carousel layadmin-carousel layadmin-shortcut card" 
										style="width: 100%;" >
									
									 
									  	 <table style="width:100%">		
									  	      <thead>
									  	        <tr>
									  	          <th align="left">标题</th>
									  	          <th align="left">内容</th>
									  	          <th colspan="6" align="right">时间</th>
									  	        </tr>
									  	      </thead>	
									  	      <tbody>						  									  	    
									  	      <tr th:each="att:${attList}">	
									  	       <td th:text="${att.title}"></td>
									  	        <td th:text="${att.msg}"></td>
									  	        <td th:text="${att.date}" colspan="6" align="right"></td>     
									  	      </tr>		
									  	      </tbody>							  	    									  	    
									  	 </table>
									  	 
									  </div>
									
									 
								</div> 
							</div>
						</div>
						<div class="layui-col-md12">
							<div class="layui-card">
								<div class="layui-card-header">在招职位</div>
								<div class="layui-card-body">
									<table id="demo" lay-filter="test"></table>
								</div>
							</div>
						</div>
					</div>
				</div>

			</div>
		</div>
	
		<script type="text/html" id="barDemo">
			<a class="layui-btn layui-btn-xs" lay-event="detail">查看</a>
			<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
			<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
		</script>
		
		<script id="toolbarDemo" type="text/html">
         <!--
          <div class="layui-btn-container">
            <button class="layui-btn layui-btn-sm" lay-event="getCheckLength">获取选中数目</button>
            <button class="layui-btn layui-btn-sm" lay-event="isAll">验证是否全选</button>
            <button class="layui-btn layui-btn-sm" lay-event="add">添加用户</button>
          </div>
         -->
    <div class="layui-inline">
    
     <div class="layui-input-inline" style="width:200px;height:38px;">
       <input type="text" name="likeDate" id="likeDate" required lay-verify="required" placeholder="请输入职位名" class="layui-input">
     </div>
     <div class="layui-inline">
       <button class="layui-btn layui-btn-sm"  data-type="reload" id="search"><i class="layui-icon">&#xe615;</i>搜索</button>
     </div>  
    </div>
        </script>
 
        <script id="attendance" type="text/html">
          <form class="layui-form">
             <div class="layui-form-item">
                <label class="layui-form-label">时间</label>
                <div class="layui-input-inline">
                   <input class="layui-input" type="text" name="time" id="time">
                </div>
             </div>

             <div class="layui-form-item" style="display:none">
                <label class="layui-form-label">工号</label>
                <div class="layui-input-inline">
                   <input class="layui-input" type="text" name="empNo" id="empNo" th:value="${session.loginUser.account}">
                </div>
             </div>

             <div class="layui-form-item" style="display:none">
                <label class="layui-form-label">姓名</label>
                <div class="layui-input-inline">
                   <input class="layui-input" type="text" name="userName" id="userName" th:value="${session.loginUser.userName}">
                </div>
             </div>

             <div class="layui-form-item">
                <label class="layui-form-label">类型</label>
                <div class="layui-input-inline">
                   <select name="type" id="type">
                      <option value="上班">上班</option>
                      <option value="下班">下班</option>
                   </select>
                </div>
             </div>
          </form>
        </script>
        
 <!-- 请假layer -->
   <script id="vacate" type="text/html">
     <form class="layui-form">
      <div class="layui-form-item">
        <label class="layui-form-label">请假类型</label>
        <div class="layui-input-inline">
           <select name="type" id="type">
             <option value="事假">事假</option>
             <option value="病假">病假</option>
             <option value="婚假">婚假</option>
             <option value="丧假">丧假</option>
             <option value="出差">出差</option>
           </select>
        </div>
      </div>
      
      <div class="layui-form-item">
      <div class="layui-block">
        <label class="layui-form-label">时间</label>
        <div class="layui-input-inline" style="width:100px;">
          <input class="layui-input" type="text" name="starTime" id="starTime" placeholder="开始日期" lay-verify="required">
        </div>
        <div class="layui-form-mid">--</div>
        <div class="layui-input-inline" style="width:100px;">
          <input class="layui-input" type="text" name="endTime" id="endTime" placeholder="结束日期" lay-verify="required">
        </div>
      </div>
      </div>
     </form>
  </script>
		<script src="layui/layui.js"></script>
		
		<script th:inline="none">
		layui.use('table',function(){
			  var table=layui.table;
			  var $=layui.jquery;
			  
			  //在招职位表格
			  table.render({
				 elem:'#demo',
				 url:'/getOpenPosition',
				 method:'post',
			     toolbar:'#toolbarDemo',
			     defaultToolbar:['filter','exports','print',{title:'提示',layEvent:'LAYTABLE_TIPS',icon:'layui-icon-tips'}],
			     title:'用户数据表',
			   //  response:{statusCode:200},
			     cols:[[
			    	// {type:'checkbox',fixed:'left'},
			    	 {field:'id',title:'ID',width:80,fixed:'left',unresize:true,sort:true},
			    	 {field:'positionName',title:'职位名称',width:130,edit:'text'},
			    	// {field:'email', title:'邮箱', width:150, edit: 'text', templet: function(res){
			    	//        return '<em>'+ res.email +'</em>'
			    	 //     }},
			    	 {field:'slary', title:'薪资', width:80, edit: 'text', sort: true}
			    	 ,{field:'require', title:'岗位要求'}
			    	 ,{field:'workPlace', title:'工作地',width:100}
			    	 ,{field:'reqnum', title:'需求人数', width:80, sort: true}
			    	 ,{field:'releaseTime', title:'发布时间', width:120},
			    	 
			    	// {fixed: 'right', title:'操作', toolbar: '#barDemo', width:200}
			     ]],
			     page:true
			  });
			  
			  table.on('toolbar(test)',function(obj){
				  var checkStatus=table.checkStatus(obj.config.id);
				  switch(obj.event){
				  case 'add':
					  var data=checkStatus.data;
					 layer.alert(JSON.stringify(data));
					  
				  break;
				  case 'getCheckLength':
					  var data=checkStatus.data;
					  layer.msg('选中了：'+data.length+'个');
				  break;
				  case 'isAll':
					  layer.msg(checkStatus.isAll?'全选':'未全选');
				  break;
				  case 'LAYTABLE_TIPS':
					  layer.alert('这是工具栏右侧自定义的一个图标按钮');
				  break;
				  };
			  });
			  
			  //监听行工具事件
			  table.on('tool(test)',function(obj){
				  
			
			  });
		  });
		
		//监听打卡
		function attendance(){
			layui.use('layer',function(){
				var layer=layui.layer;
				var $=layui.jquery;
				layui.use('form',function(){
				var form =layui.form;
				var index=layer.open({
					formType:1,
					title:'打卡',
					content:$('#attendance').html(),
					btn:['确认','取消'],
					area:['380px','220px'],
					offset:'80px',
					yes:function(){
						var time=$('#time').val();
						var type=$('#type').val();
						var userName=$('#userName').val();
						var empNo=$('#empNo').val();
						$.ajax({
							url:'/addAttendance',
							method:'post',
							contentType:'application/json;charset=utf-8',
							data:JSON.stringify({empNo:empNo,userName:userName,time:time,type:type}),
							success:function(msg){
								if(msg){
									layer.msg("打卡成功")
								}else{
									layer.msg("打卡失败")
								}
							},
							error:function(msg){
								layer.msg("系统错误，打卡失败");
							}
						});
					},
					btn2:function(index){layer.close(index);},
					success:function(){
						form.render();
						layui.use('laydate',function(){
							var laydate=layui.laydate;
							laydate.render({
								elem:'#time',
								type:'datetime',
								value:new Date(),
							});
						});
					}
				});
				});
			});
		}
		//监听请假
		
		function vacate(){
			layui.use('layer',function(){
				var layer=layui.layer;
				var $=layui.jquery;
				layui.use('form',function(){
				var form=layui.form;	
				var index=layer.open({
					formType:1,
					title:'请假',
					content:$('#vacate').html(),
					btn:['确认','取消'],
					area:['450px','250px'],
					offset:'80px',
					yes:function(){
						var endTime=$('#endTime').val();
						var starTime=$('#starTime').val();
						var type=$('#type').val();
						$.ajax({
							url:'/addManaVacate',
							method:'post',
							contentType:'application/json;charset=utf-8',
							data:JSON.stringfiy({type:type,endTime:endTime,starTime:starTime}),
							success:function(mag){
								if(msg){
									layer.msg("申请成功");
								}else{
									layer.msg("申请失败");
								}
							},
							error:function(){
								layer.alert("系统错误，申请失败");
							}
						});
					},
					btn2:function(index){layer.close(index);},
					success:function(){						
						layui.use('laydate',function(){
							var laydate=layui.laydate;
							laydate.render({
								elem:'#starTime',
								type:'date',
								min:0,
							});
							laydate.render({
								elem:'#endTime',
								type:'date',
								min:0,
							});
						});
						form.render();
					}
				});
				});
			});
		}
		</script>
	</body>
</html>
